<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>小说管理后台</title>
    <link rel="stylesheet/less" href="../../../static/admin/css/index.less"/>
    <link rel="stylesheet" href="../../../static/admin/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/admin/css/jquery.pagination.css"/>
    <script src="../../../static/admin/js/jquery-1.12.3.js"></script>
    <script src="../../../static/admin/js/less.min.js"></script>
    <script src="../../../static/admin/layui/layui.js"></script>
    <SCRIPT language=javascript src="../../../static/layer/jquery-1.9.1.min.js"></SCRIPT>
    <SCRIPT language=javascript src="../../../static/layer/layer.js"></SCRIPT>
     <script src="../../../static/admin/js/ajaxfileupload.js"></script>
</head>
<style>
    .js_w {
        width: 40px;
        height: 25px;
        font-size: 12px;
        line-height: 25px;
    }

    .ll {
        width: 40px;
        height: 25px;
        font-size: 12px;
        line-height: 25px;
    }

    .newadd label {
        padding: 10px 0;
        display: block;
        text-align: left;
    }

    .newadd label .adtitle {
        display: inline-block;
        width: 6rem;
        text-align: right;
        padding-right: 2%;
    }

    .newadd label span {
        text-align: right;
        padding-right: 2%;
    }

    .newadd input {
        padding: 0 10px;
        width: 20%;
        height: 30px;
        line-height: 30px;
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .newadd select {
        text-align: left;
        padding: 0 5px;
        width: 20%;
        height: 30px;
        line-height: 30px;
        border: 1px solid #dcdcdc;
        border-radius: 5px;
    }

    .subbtn {
        margin-left: 8%;
        padding: 2px 3px;
    }
</style>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

    {% include "/admin/left.html" %}

    <div class="layui-body">
        <div id="box" class="fl">
            <div class="content">
                <h3>新增版本</h3>
                <div class="newadd">
                    <label>
                        <span class="adtitle">版本号：</span>
                        <input value="" type="text" id="version_code"  onkeyup="value=value.replace(/[^\d]/g,'')">
                    </label>
                    <label>
                        <span class="adtitle">版本名：</span>
                        <input id="version_name" type="text" value="">
                    </label>
                    <label>
                        <span class="adtitle">版本文件</span>
                        <input type="file" id="xdaTanFileImg" name="all_file" value=""/></label>
                    <label>
                        <button class="subbtn" id="btn">提交</button>
                    </label>
                </div>
            </div>
        </div>
    </div>
</div>
</div>
</body>
</html>
<script>
    $(function () {
        $('#btn').click(function () {
            var version_code= $('#version_code').val();
            var version_name = $('#version_name').val();
            var file = $('#xdaTanFileImg').val()
            if (file == "") {
                layer.msg('请选择照片！');
                return
            }
            $.ajaxFileUpload({
                type: 'post',
                url: '/admin/version/add.html',
                data: {
                    'version_code': version_code,
                    'version_name': version_name,
                },
                secureuri: false,
                fileElementId: 'xdaTanFileImg',
                dataType: 'json',
                success: function (msg) {
                    if (msg.status == 1) {
                        layer.msg('增加成功', {time: 2000}, function () {
                            location.href = "/admin/version/list.html";
                        });
                    } else {
                        layer.msg('增加失败', {time: 2000});
                    }
                }
            });
        });
    })

</script>
